package com.kaifamiao.memory;

import java.io.CharArrayReader;
import java.io.CharArrayWriter;
import java.io.IOException;

public class CharArrayTest {

    public static void main(String[] args) throws IOException {

        // 创建一个 字符数组 输出流 (内部用字符数组缓存数据)
        CharArrayWriter caw = new CharArrayWriter();

        caw.write( '芳' );
        caw.write( ':' );
        caw.write( '\n' );
        caw.write( '\t' );
        caw.write( "最近睡觉怎么样啊?" );

        caw.close();

        final char[] chars = caw.toCharArray();

        // 创建一个 字符数组 输入流 (用于从指定字符数组中读取数据)
        CharArrayReader car = new CharArrayReader(chars);

        System.out.println( (char)car.read() );
        car.skip(3);
        String s = "";
        int ch;
        while( ( ch = car.read() ) != -1 ){
            char c = (char)ch;
            s += c;
        }
        System.out.println( s );


    }

}
